< previous page page_754 next page >

Page 754
Type.gifListing 19.26. Coding the cmdAction_Click event.
Private Sub cmdAction_Click(Index As Integer)
    '
    ' handle action selections
    '
    Select Case Index
        Case 0 ' add
            sqlField(0) = ""
            sqlField(1) = ""
            blnAdding = True
        Case 1 ' delete
            If blnAdding = True Then
                blnAdding = False
            End If
            objSQL.DelRow Me
        Case 2 ' udpate
            If blnAdding = True Then
                objSQL.AddRow Me
                blnAdding = False
            Else
                objSQL.UpdateRow Me
            End If
        Case 3 ' close
            objSQL.Disconnect
            Unload Me
    End Select
    '
End Sub
Note.gif
The code in Listing 19.26 is only the most basic code needed to add, delete, and update a record. If you want to use this form in a production setting, you should add code to confirm deletes and enable users to cancel updates or adds.

Now save the project as PRJTEST.VBP. You now are ready to run the ODBC data-entry form.
Running the ODBC Data-Entry Form
Now that both the library and the form routines are completed, you are ready to run the program. When you first run the program, you see the data-entry form with the first record displayed, as shown in Figure 19.11.
You now can use this screen to walk through the dataset by using the command buttons (First, Last, Next, and Back). You also can add, edit, and delete records in the dataset by using the appropriate buttons.

 
< previous page page_754 next page >

If you like this book, buy it!